***************Treatment Differences (Result 1 - Draws)*********************************

import delimited "ContestLevelDraws2.csv", clear

egen session=group(sessionid)
xtset session
xtreg final_draws treatment, re
xtreg final_draws treatment, fe


***************Treatment Differences (Innovations)***************************

import delimited "ContestLevelWinningInnovation2.csv", clear

egen session=group(sessionid)
xtset session
xtreg final_tech treatment,re
xtreg final_tech treatment,fe



*****************Result 2***************

import delimited "TwoPerson.csv", clear

drop if treatment!=2

*Generating Variables
gen leader=0
replace leader=1 if (mycurrentbest==currentbest) & (currentbest>0)
gen follower=0
replace follower=1 if (mycurrentbest<currentbest)


summarize decision if leader==1
summarize decision if follower==1

egen subject=group(subjectid)
egen session=group(sessionid)
xtset subject

xtreg decision leader if (follower==1) | (leader==1), re cluster(session)
xtreg decision leader if (follower==1) | (leader==1), fe cluster(session)


*Dynamics (Result 3)

import delimited "TwoPerson.csv", clear

drop if treatment!=2
gen period=mod(decisionnumber,10)
replace period=10 if period==0

egen subject=group(subjectid)
egen session=group(sessionid)
xtset subject

clogit decision currentbest if period==2, group(subject) cluster(session)
clogit decision currentbest if period==3, group(subject) cluster(session)
clogit decision currentbest if period==4, group(subject) cluster(session)
clogit decision currentbest if period==5, group(subject) cluster(session)
clogit decision currentbest if period==6, group(subject) cluster(session)
clogit decision currentbest if period==7, group(subject) cluster(session)
clogit decision currentbest if period==8, group(subject) cluster(session)
clogit decision currentbest if period==9, group(subject) cluster(session)
clogit decision currentbest if period==10, group(subject) cluster(session)

xtlogit decision currentbest if period==2, re vce (cluster session)
xtlogit decision currentbest if period==3, re vce (cluster session)
xtlogit decision currentbest if period==4, re vce (cluster session)
xtlogit decision currentbest if period==5, re vce (cluster session)
xtlogit decision currentbest if period==6, re vce (cluster session)
xtlogit decision currentbest if period==7, re vce (cluster session)
xtlogit decision currentbest if period==8, re vce (cluster session)
xtlogit decision currentbest if period==9, re vce (cluster session)
xtlogit decision currentbest if period==10, re vce (cluster session)


import delimited "TwoPerson.csv", clear

drop if treatment!=1
gen period=mod(decisionnumber,10)
replace period=10 if period==0

egen subject=group(subjectid)
egen session=group(sessionid)
xtset subject

clogit decision mycurrentbest if period==2, group(subject) cluster(session)
clogit decision mycurrentbest if period==3, group(subject) cluster(session)
clogit decision mycurrentbest if period==4, group(subject) cluster(session)
clogit decision mycurrentbest if period==5, group(subject) cluster(session)
clogit decision mycurrentbest if period==6, group(subject) cluster(session)
clogit decision mycurrentbest if period==7, group(subject) cluster(session)
clogit decision mycurrentbest if period==8, group(subject) cluster(session)
clogit decision mycurrentbest if period==9, group(subject) cluster(session)
clogit decision mycurrentbest if period==10, group(subject) cluster(session)

xtlogit decision mycurrentbest if period==2, re vce (cluster session)
xtlogit decision mycurrentbest if period==3, re vce (cluster session)
xtlogit decision mycurrentbest if period==4, re vce (cluster session)
xtlogit decision mycurrentbest if period==5, re vce (cluster session)
xtlogit decision mycurrentbest if period==6, re vce (cluster session)
xtlogit decision mycurrentbest if period==7, re vce (cluster session)
xtlogit decision mycurrentbest if period==8, re vce (cluster session)
xtlogit decision mycurrentbest if period==9, re vce (cluster session)
xtlogit decision mycurrentbest if period==10, re vce (cluster session)

